package com.cskaoyan.service.wx.feedback;

import com.cskaoyan.bean.MarketAdmin;
import com.cskaoyan.bean.MarketFeedback;
import com.cskaoyan.bean.MarketUser;
import com.cskaoyan.mapper.MarketFeedbackMapper;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.Date;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: bwj
 * @Date: 2022/09/09/23:13
 * @Description:
 */
@Service
public class FeedbackServiceImpl implements FeedbackService {
    @Autowired
    MarketFeedbackMapper feedbackMapper;

    @Override
    public void submit(MarketFeedback submitBo) {
        MarketUser principal = null;
        try {
            Subject subject = SecurityUtils.getSubject();
            principal = (MarketUser) subject.getPrincipals().getPrimaryPrincipal();
        } catch (Exception e) {
            e.printStackTrace();
            return;
        }
        submitBo.setUserId(principal.getId());
        submitBo.setAddTime(new Date());
        submitBo.setStatus(0);
        submitBo.setUpdateTime(new Date());
        submitBo.setUsername(principal.getUsername());
        feedbackMapper.insertSelective(submitBo);
    }
}
